<page-header [autoTitle]="false"></page-header>
<nz-card>
  <section class="search-section">
    <input nz-input placeholder="姓名、手机" [(ngModel)]="keyword" class="search-item"/>
    <nz-select [(ngModel)]="agentId" [nzPlaceHolder]="'所属渠道'" class="search-item" [nzShowSearch]="true" [nzAllowClear]="true">
      <nz-option
        *ngFor="let option of allAgents"
        [nzLabel]="option.name"
        [nzValue]="option.id">
      </nz-option>
    </nz-select>
    <button nz-button [nzType]="'primary'" nzGhost (click)="search()" class="search-item">
      <i class="anticon anticon-search"></i><span>搜索</span>
    </button>
  </section>
  <nz-table #nzTable [nzData]="page.content"
            [nzPageSize]="page.size"
            [nzTotal]="page.totalElements"
            [nzFrontPagination]="false"
            [(nzPageIndex)]="page.number"
            (nzPageIndexChange)="changePageNo($event)"
            [nzLoading]="isLoading">
    <thead>
    <tr>
      <th nz-th><span>序号</span></th>
      <th nz-th><span>姓名</span></th>
      <th nz-th><span>手机</span></th>
      <th nz-th><span>所属渠道</span></th>
      <th nz-th><span>加入时间</span></th>
      <th nz-th><span>最后登录时间</span></th>
      <th nz-th><span>操作</span></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of nzTable.data;let i=index">
      <td>
        {{i+1}}
      </td>
      <td>{{data.name}}</td>
      <td>{{data.phone}}</td>
      <td>{{data.agentId|dicsNamePipe:allAgents:"id":"name"}}</td>
      <td>{{data.saveDate}}</td>
      <td>{{data.lastLoginTime}}</td>
      <td>
        <a href="javascript:void (0);" (click)="editEntity(data)">查看详情</a>
        <nz-divider nzType="vertical"></nz-divider>
        <nz-popconfirm [nzTitle]="'禁止下单，该用户将不能进行下单购买操作，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'orderPermission':2},'permissionReason')">
          <a nz-popconfirm  *ngIf="data.orderPermission == 1">禁止下单</a>
        </nz-popconfirm>
        <nz-popconfirm [nzTitle]="'恢复正常下单，该用户将恢复正常下单购买操作，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'orderPermission':1},null)">
          <a nz-popconfirm  *ngIf="data.orderPermission == 2">恢复正常下单</a>
        </nz-popconfirm>
      </td>
    </tr>
    </tbody>
  </nz-table>
</nz-card>
